
#ifndef DRAWGEOSPHEREHANDLER_H
#define DRAWGEOSPHEREHANDLER_H

#include <BImage>
#include <BPicker>
#include <BHandler>
#include <BGeoSphere>

#include "../Target.h"
#include "EdgePicker.h"
#include "AdsorbVertexPicker.h"
#include "VertexTransformer.h"

class DrawGeoSphereHandler : public BHandler
{
public:
	DrawGeoSphereHandler(BHandler* parent = 0);
	~DrawGeoSphereHandler();

protected:
	void slotAssetChanged(BObject* object, const BValue& value);
	void slotPropertyChanged(BObject* object, const BValue& value);

protected:
	virtual void attached(BViewer* viewer);
	virtual void detached(BViewer* viewer);

	virtual void paint(BPainter& painter);
	virtual void render(BRender& render);

	virtual void updateEvent(const BEvent& event);
	virtual void styleEvent(const BEvent& event);
	virtual void freshEvent(const BEvent& event);

	virtual void keyPressEvent(const BKeyEvent& keyEvent);
	virtual void keyReleaseEvent(const BKeyEvent& keyEvent);

	virtual void mouseEnterEvent(const BMouseEvent& mouseEvent);
	virtual void mouseLeaveEvent(const BMouseEvent& mouseEvent);
	virtual void mousePressEvent(const BMouseEvent& mouseEvent);
	virtual void mouseReleaseEvent(const BMouseEvent& mouseEvent);
	virtual void mouseMoveEvent(const BMouseEvent& mouseEvent);

private:
	BHolder<AdsorbVertexPicker>		_vertexPicker;
	BHolder<EdgePicker>				_edgePicker;
	BHolder<BGeoSphere>				_geosphere;
	BHolder<BImage>					_dragImage;

	BHolder<BPickHit>		_hoveredHit;
	BVector					_point;
	BLine					_baseLine;
	BPlane					_basePlane;
	int						_hoveredIndex;
	BVectorArray			_vertices;
};

#endif
